<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

include ("../conn/conn.php");
$conn = prepare();

while(list($name,$value)=each($_POST)){
    if ($name!="submit") {
        $stmt = exectue_sql_statement($conn, "select count(*) as total from Book where classify_id=$value");
	$info = sqlsrv_fetch_array($stmt);
	if($info['total'] != 0) {
            echo"<script>alert('请删除该类别下的所有图书后再删除该类别!');window.location.href='showclass.php';</script>";
            exit();
        }
        
        exectue_sql_statement($conn, "delete from Classification where classify_id=$value");
    }
}
echo "<script>alert('类别删除成功!');window.location.href='showclass.php';</script>";
?>